home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0036_Read Key - NO REMOVE.pas < prev    next >
Pascal/Delphi Source File  |  1993-08-18  |  1KB  |  34 lines

  1. { Reads a key from the keyboard buffer, WITHOUT removing it.
  2.   Part of the Heartware Toolkit v2.00 (HTkey1.PAS) for Turbo Pascal.
  3.   Author: Jose Almeida. P.O.Box 4185. 1504 Lisboa Codex. Portugal.
  4.           I can also be reached at RIME network, site ->TIB or #5314.
  5.   Feel completely free to use this source code in any way you want, and, if
  6.   you do, please don't forget to mention my name, and, give me and Swag the
  7.   proper credits. }
  8.  
  9. FUNCTION Read_Key : word;
  10. { DESCRIPTION:
  11.     Reads a key from the keyboard buffer, WITHOUT removing it.
  12.   SAMPLE CALL:
  13.     NW := Read_Key;
  14.   RETURNS:
  15.     The scan code of the key that is ready to be readen from the buffer, or,
  16.       if there is no key in the buffer, returns $FFFF value.
  17.   NOTES:
  18.     This is a special function. It's only to be called in very special
  19.       situations. It checks if a key is ready in the keyboard
  20.       buffer. If there is a key, then the key is readed but NOT removed
  21.       from the buffer. The key will remain in the buffer. }
  22.  
  23. var
  24.   HTregs : registers;
  25.  
  26. BEGIN { Read_Key }
  27.   HTregs.AH := $01;
  28.   Intr($16,HTregs);
  29.   if not (HTregs.Flags and FZero <> 0) then
  30.     Read_Key := HTregs.AX
  31.   else
  32.     Read_Key := $FFFF;
  33. END; { Read_Key }
  34.